package com.jp.memory;

public class MyTest3 {
    public static void main(String[] args) {
        new Thread(()->{A.method();}).start();
        new Thread(()->{B.method();}).start();
    }

}

class A{
    public static synchronized void method(){
        System.out.println("class A");
        try {
            Thread.sleep(5000);
            B.method();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

class B{
    public static synchronized void method(){

        System.out.println("class B");
        try {
            Thread.sleep(5000);
            A.method();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
